package rth.entities;

import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.proxy.HibernateProxy;

import rth.entities.iface.ITestset;

import com.felees.hbnpojogen.persistence.IPojoGenEntity;

/**
 * Object mapping for hibernate-handled table: testset.
 * 
 * @author autogenerated
 */

@Entity
@Table(name = "testset", catalog = "rth")
public class Testset implements Cloneable, Serializable, IPojoGenEntity,
		ITestset {

	/** Serial Version UID. */
	private static final long serialVersionUID = -559033189L;

	/**
	 * Use a WeakHashMap so entries will be garbage collected once all entities
	 * referring to a saved hash are garbage collected themselves.
	 */
	private static final Map<Serializable, Long> SAVED_HASHES = Collections
			.synchronizedMap(new WeakHashMap<Serializable, Long>());

	/** hashCode temporary storage. */
	private volatile Long hashCode;

	/** Field mapping. */
	private String archive;
	/** Field mapping. */
	private Long buildid;
	/** Field mapping. */
	private String datecreated;
	/** Field mapping. */
	private String description;
	/** Field mapping. */
	private Long id = 0L; // init for hibernate bug workaround
	/** Field mapping. */
	private String lockby;
	/** Field mapping. */
	private String lockchangedate;
	/** Field mapping. */
	private String lockcomment;
	/** Field mapping. */
	private String locked;
	/** Field mapping. */
	private String signoffby;
	/** Field mapping. */
	private String signoffcomments;
	/** Field mapping. */
	private String signoffdate;
	/** Field mapping. */
	private String testsetname;
	/** Field mapping. */
	private Integer testsetorderby;
	/** Field mapping. */
	private String testsetstatus;
	/** Field mapping. */
	private String testsettype;
	/** Field mapping. */
	private String uniqueid;

	/**
	 * Default constructor, mainly for hibernate use.
	 */
	public Testset() {
		// Default constructor
	}

	/**
	 * Constructor taking a given ID.
	 * 
	 * @param id
	 *            to set
	 */
	public Testset(Long id) {
		this.id = id;
	}

	/**
	 * Constructor taking a given ID.
	 * 
	 * @param archive
	 *            String object;
	 * @param buildid
	 *            Long object;
	 * @param datecreated
	 *            String object;
	 * @param id
	 *            Long object;
	 * @param locked
	 *            String object;
	 * @param signoffby
	 *            String object;
	 * @param signoffcomments
	 *            String object;
	 * @param signoffdate
	 *            String object;
	 * @param testsetname
	 *            String object;
	 * @param testsetorderby
	 *            Integer object;
	 * @param testsetstatus
	 *            String object;
	 * @param uniqueid
	 *            String object;
	 */
	public Testset(String archive, Long buildid, String datecreated, Long id,
			String locked, String signoffby, String signoffcomments,
			String signoffdate, String testsetname, Integer testsetorderby,
			String testsetstatus, String uniqueid) {

		this.archive = archive;
		this.buildid = buildid;
		this.datecreated = datecreated;
		this.id = id;
		this.locked = locked;
		this.signoffby = signoffby;
		this.signoffcomments = signoffcomments;
		this.signoffdate = signoffdate;
		this.testsetname = testsetname;
		this.testsetorderby = testsetorderby;
		this.testsetstatus = testsetstatus;
		this.uniqueid = uniqueid;
	}

	/**
	 * Return the type of this class. Useful for when dealing with proxies.
	 * 
	 * @return Defining class.
	 */
	@Transient
	public Class<?> getClassType() {
		return Testset.class;
	}

	/**
	 * Return the value associated with the column: archive.
	 * 
	 * @return A String object (this.archive)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 3)
	public String getArchive() {
		return this.archive;

	}

	/**
	 * Set the value related to the column: archive.
	 * 
	 * @param archive
	 *            the archive value you wish to set
	 */
	public void setArchive(final String archive) {
		this.archive = archive;
	}

	/**
	 * Return the value associated with the column: buildid.
	 * 
	 * @return A Long object (this.buildid)
	 */
	@Basic(optional = false)
	@Column(nullable = false)
	public Long getBuildid() {
		return this.buildid;

	}

	/**
	 * Set the value related to the column: buildid.
	 * 
	 * @param buildid
	 *            the buildid value you wish to set
	 */
	public void setBuildid(final Long buildid) {
		this.buildid = buildid;
	}

	/**
	 * Return the value associated with the column: datecreated.
	 * 
	 * @return A String object (this.datecreated)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 19)
	public String getDatecreated() {
		return this.datecreated;

	}

	/**
	 * Set the value related to the column: datecreated.
	 * 
	 * @param datecreated
	 *            the datecreated value you wish to set
	 */
	public void setDatecreated(final String datecreated) {
		this.datecreated = datecreated;
	}

	/**
	 * Return the value associated with the column: description.
	 * 
	 * @return A String object (this.description)
	 */
	@Basic(optional = true)
	@Column(length = 21845)
	public String getDescription() {
		return this.description;

	}

	/**
	 * Set the value related to the column: description.
	 * 
	 * @param description
	 *            the description value you wish to set
	 */
	public void setDescription(final String description) {
		this.description = description;
	}

	/**
	 * Return the value associated with the column: id.
	 * 
	 * @return A Long object (this.id)
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Basic(optional = false)
	@Column(name = "testsetid", nullable = false)
	public Long getId() {
		return this.id;

	}

	/**
	 * Set the value related to the column: id.
	 * 
	 * @param id
	 *            the id value you wish to set
	 */
	public void setId(final Long id) {
		// If we've just been persisted and hashCode has been
		// returned then make sure other entities with this
		// ID return the already returned hash code
		if ((this.id == null || this.id == 0L) && (id != null)
				&& (this.hashCode != null)) {
			SAVED_HASHES.put(id, this.hashCode);
		}
		this.id = id;
	}

	/**
	 * Return the value associated with the column: lockby.
	 * 
	 * @return A String object (this.lockby)
	 */
	@Basic(optional = true)
	@Column(length = 25)
	public String getLockby() {
		return this.lockby;

	}

	/**
	 * Set the value related to the column: lockby.
	 * 
	 * @param lockby
	 *            the lockby value you wish to set
	 */
	public void setLockby(final String lockby) {
		this.lockby = lockby;
	}

	/**
	 * Return the value associated with the column: lockchangedate.
	 * 
	 * @return A String object (this.lockchangedate)
	 */
	@Basic(optional = true)
	@Column(length = 19)
	public String getLockchangedate() {
		return this.lockchangedate;

	}

	/**
	 * Set the value related to the column: lockchangedate.
	 * 
	 * @param lockchangedate
	 *            the lockchangedate value you wish to set
	 */
	public void setLockchangedate(final String lockchangedate) {
		this.lockchangedate = lockchangedate;
	}

	/**
	 * Return the value associated with the column: lockcomment.
	 * 
	 * @return A String object (this.lockcomment)
	 */
	@Basic(optional = true)
	@Column(length = 21845)
	public String getLockcomment() {
		return this.lockcomment;

	}

	/**
	 * Set the value related to the column: lockcomment.
	 * 
	 * @param lockcomment
	 *            the lockcomment value you wish to set
	 */
	public void setLockcomment(final String lockcomment) {
		this.lockcomment = lockcomment;
	}

	/**
	 * Return the value associated with the column: locked.
	 * 
	 * @return A String object (this.locked)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 1)
	public String getLocked() {
		return this.locked;

	}

	/**
	 * Set the value related to the column: locked.
	 * 
	 * @param locked
	 *            the locked value you wish to set
	 */
	public void setLocked(final String locked) {
		this.locked = locked;
	}

	/**
	 * Return the value associated with the column: signoffby.
	 * 
	 * @return A String object (this.signoffby)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 19)
	public String getSignoffby() {
		return this.signoffby;

	}

	/**
	 * Set the value related to the column: signoffby.
	 * 
	 * @param signoffby
	 *            the signoffby value you wish to set
	 */
	public void setSignoffby(final String signoffby) {
		this.signoffby = signoffby;
	}

	/**
	 * Return the value associated with the column: signoffcomments.
	 * 
	 * @return A String object (this.signoffcomments)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 255)
	public String getSignoffcomments() {
		return this.signoffcomments;

	}

	/**
	 * Set the value related to the column: signoffcomments.
	 * 
	 * @param signoffcomments
	 *            the signoffcomments value you wish to set
	 */
	public void setSignoffcomments(final String signoffcomments) {
		this.signoffcomments = signoffcomments;
	}

	/**
	 * Return the value associated with the column: signoffdate.
	 * 
	 * @return A String object (this.signoffdate)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 19)
	public String getSignoffdate() {
		return this.signoffdate;

	}

	/**
	 * Set the value related to the column: signoffdate.
	 * 
	 * @param signoffdate
	 *            the signoffdate value you wish to set
	 */
	public void setSignoffdate(final String signoffdate) {
		this.signoffdate = signoffdate;
	}

	/**
	 * Return the value associated with the column: testsetname.
	 * 
	 * @return A String object (this.testsetname)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 30)
	public String getTestsetname() {
		return this.testsetname;

	}

	/**
	 * Set the value related to the column: testsetname.
	 * 
	 * @param testsetname
	 *            the testsetname value you wish to set
	 */
	public void setTestsetname(final String testsetname) {
		this.testsetname = testsetname;
	}

	/**
	 * Return the value associated with the column: testsetorderby.
	 * 
	 * @return A Integer object (this.testsetorderby)
	 */
	@Basic(optional = false)
	@Column(nullable = false)
	public Integer getTestsetorderby() {
		return this.testsetorderby;

	}

	/**
	 * Set the value related to the column: testsetorderby.
	 * 
	 * @param testsetorderby
	 *            the testsetorderby value you wish to set
	 */
	public void setTestsetorderby(final Integer testsetorderby) {
		this.testsetorderby = testsetorderby;
	}

	/**
	 * Return the value associated with the column: testsetstatus.
	 * 
	 * @return A String object (this.testsetstatus)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 40)
	public String getTestsetstatus() {
		return this.testsetstatus;

	}

	/**
	 * Set the value related to the column: testsetstatus.
	 * 
	 * @param testsetstatus
	 *            the testsetstatus value you wish to set
	 */
	public void setTestsetstatus(final String testsetstatus) {
		this.testsetstatus = testsetstatus;
	}

	/**
	 * Return the value associated with the column: testsettype.
	 * 
	 * @return A String object (this.testsettype)
	 */
	@Basic(optional = true)
	@Column(length = 30)
	public String getTestsettype() {
		return this.testsettype;

	}

	/**
	 * Set the value related to the column: testsettype.
	 * 
	 * @param testsettype
	 *            the testsettype value you wish to set
	 */
	public void setTestsettype(final String testsettype) {
		this.testsettype = testsettype;
	}

	/**
	 * Return the value associated with the column: uniqueid.
	 * 
	 * @return A String object (this.uniqueid)
	 */
	@Basic(optional = false)
	@Column(nullable = false, length = 15)
	public String getUniqueid() {
		return this.uniqueid;

	}

	/**
	 * Set the value related to the column: uniqueid.
	 * 
	 * @param uniqueid
	 *            the uniqueid value you wish to set
	 */
	public void setUniqueid(final String uniqueid) {
		this.uniqueid = uniqueid;
	}

	/**
	 * Deep copy.
	 * 
	 * @return cloned object
	 * @throws CloneNotSupportedException
	 *             on error
	 */
	@Override
	public Testset clone() throws CloneNotSupportedException {

		final Testset copy = (Testset) super.clone();

		copy.setArchive(this.getArchive());
		copy.setBuildid(this.getBuildid());
		copy.setDatecreated(this.getDatecreated());
		copy.setDescription(this.getDescription());
		copy.setId(this.getId());
		copy.setLockby(this.getLockby());
		copy.setLockchangedate(this.getLockchangedate());
		copy.setLockcomment(this.getLockcomment());
		copy.setLocked(this.getLocked());
		copy.setSignoffby(this.getSignoffby());
		copy.setSignoffcomments(this.getSignoffcomments());
		copy.setSignoffdate(this.getSignoffdate());
		copy.setTestsetname(this.getTestsetname());
		copy.setTestsetorderby(this.getTestsetorderby());
		copy.setTestsetstatus(this.getTestsetstatus());
		copy.setTestsettype(this.getTestsettype());
		copy.setUniqueid(this.getUniqueid());
		return copy;
	}

	/**
	 * Provides toString implementation.
	 * 
	 * @see java.lang.Object#toString()
	 * @return String representation of this class.
	 */
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();

		sb.append("archive: " + this.getArchive() + ", ");
		sb.append("buildid: " + this.getBuildid() + ", ");
		sb.append("datecreated: " + this.getDatecreated() + ", ");
		sb.append("description: " + this.getDescription() + ", ");
		sb.append("id: " + this.getId() + ", ");
		sb.append("lockby: " + this.getLockby() + ", ");
		sb.append("lockchangedate: " + this.getLockchangedate() + ", ");
		sb.append("lockcomment: " + this.getLockcomment() + ", ");
		sb.append("locked: " + this.getLocked() + ", ");
		sb.append("signoffby: " + this.getSignoffby() + ", ");
		sb.append("signoffcomments: " + this.getSignoffcomments() + ", ");
		sb.append("signoffdate: " + this.getSignoffdate() + ", ");
		sb.append("testsetname: " + this.getTestsetname() + ", ");
		sb.append("testsetorderby: " + this.getTestsetorderby() + ", ");
		sb.append("testsetstatus: " + this.getTestsetstatus() + ", ");
		sb.append("testsettype: " + this.getTestsettype() + ", ");
		sb.append("uniqueid: " + this.getUniqueid());
		return sb.toString();
	}

	/**
	 * Equals implementation.
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 * @param aThat
	 *            Object to compare with
	 * @return true/false
	 */
	@Override
	public boolean equals(final Object aThat) {
		Object proxyThat = aThat;

		if (this == aThat) {
			return true;
		}

		if (aThat instanceof HibernateProxy) {
			// narrow down the proxy to the class we are dealing with.
			try {
				proxyThat = ((HibernateProxy) aThat)
						.getHibernateLazyInitializer().getImplementation();
			} catch (org.hibernate.ObjectNotFoundException e) {
				return false;
			}
		}
		if (aThat == null) {
			return false;
		}

		final Testset that;
		try {
			that = (Testset) proxyThat;
			if (!(that.getClassType().equals(this.getClassType()))) {
				return false;
			}
		} catch (org.hibernate.ObjectNotFoundException e) {
			return false;
		} catch (ClassCastException e) {
			return false;
		}

		boolean result = true;
		result = result
				&& (((this.getId() == null) && (that.getId() == null)) || (this
						.getId() != null && this.getId().equals(that.getId())));
		result = result
				&& (((getArchive() == null) && (that.getArchive() == null)) || (getArchive() != null && getArchive()
						.equals(that.getArchive())));
		result = result
				&& (((getBuildid() == null) && (that.getBuildid() == null)) || (getBuildid() != null && getBuildid()
						.equals(that.getBuildid())));
		result = result
				&& (((getDatecreated() == null) && (that.getDatecreated() == null)) || (getDatecreated() != null && getDatecreated()
						.equals(that.getDatecreated())));
		result = result
				&& (((getDescription() == null) && (that.getDescription() == null)) || (getDescription() != null && getDescription()
						.equals(that.getDescription())));
		result = result
				&& (((getLockby() == null) && (that.getLockby() == null)) || (getLockby() != null && getLockby()
						.equals(that.getLockby())));
		result = result
				&& (((getLockchangedate() == null) && (that.getLockchangedate() == null)) || (getLockchangedate() != null && getLockchangedate()
						.equals(that.getLockchangedate())));
		result = result
				&& (((getLockcomment() == null) && (that.getLockcomment() == null)) || (getLockcomment() != null && getLockcomment()
						.equals(that.getLockcomment())));
		result = result
				&& (((getLocked() == null) && (that.getLocked() == null)) || (getLocked() != null && getLocked()
						.equals(that.getLocked())));
		result = result
				&& (((getSignoffby() == null) && (that.getSignoffby() == null)) || (getSignoffby() != null && getSignoffby()
						.equals(that.getSignoffby())));
		result = result
				&& (((getSignoffcomments() == null) && (that
						.getSignoffcomments() == null)) || (getSignoffcomments() != null && getSignoffcomments()
						.equals(that.getSignoffcomments())));
		result = result
				&& (((getSignoffdate() == null) && (that.getSignoffdate() == null)) || (getSignoffdate() != null && getSignoffdate()
						.equals(that.getSignoffdate())));
		result = result
				&& (((getTestsetname() == null) && (that.getTestsetname() == null)) || (getTestsetname() != null && getTestsetname()
						.equals(that.getTestsetname())));
		result = result
				&& (((getTestsetorderby() == null) && (that.getTestsetorderby() == null)) || (getTestsetorderby() != null && getTestsetorderby()
						.equals(that.getTestsetorderby())));
		result = result
				&& (((getTestsetstatus() == null) && (that.getTestsetstatus() == null)) || (getTestsetstatus() != null && getTestsetstatus()
						.equals(that.getTestsetstatus())));
		result = result
				&& (((getTestsettype() == null) && (that.getTestsettype() == null)) || (getTestsettype() != null && getTestsettype()
						.equals(that.getTestsettype())));
		result = result
				&& (((getUniqueid() == null) && (that.getUniqueid() == null)) || (getUniqueid() != null && getUniqueid()
						.equals(that.getUniqueid())));
		return result;
	}

	/**
	 * Calculate the hashcode.
	 * 
	 * @see java.lang.Object#hashCode()
	 * @return a calculated number
	 */
	@Override
	public int hashCode() {
		if (this.hashCode == null) {
			synchronized (this) {
				if (this.hashCode == null) {
					Long newHashCode = null;

					if (getId() != null) {
						newHashCode = SAVED_HASHES.get(getId());
					}

					if (newHashCode == null) {
						if (getId() != null && getId() != 0L) {
							newHashCode = getId();
						} else {
							newHashCode = (long) super.hashCode();

						}
					}

					this.hashCode = newHashCode;
				}
			}
		}
		return (int) (this.hashCode & 0xffffff);
	}

}
